<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>删除DOM</title>
</head>
<body>
	<div id="test-div">
		<p id="Python">Python</p>
		<p id="Java">Java</p>
		<p id="JavaScript">JavaScript</p>
	</div>
	<!-- 删除除了Web开发之外的其他节点 -->
	<ul id="ul-test">
		<li>JavaScript</li>
		<li>Swift</li>
		<li>HTML</li>
		<li>ANSI C</li>
		<li>CSS</li>
		<li>DirectX</li>
	</ul>
<script>
	//删除DOM节点操作
	let python = document.getElementById("Python");
	let parentElement = python.parentElement;
	let removed = parentElement.removeChild(python);
	console.log(python === removed);

	//删除除了Web开发之外的其他节点
	let
		childrenList = document.getElementById("ul-test").children,
		webs = ["JavaScript","CSS","HTML"];
	for (let child of childrenList) {
		if (!webs.includes(child.innerText)) {
			child.parentElement.removeChild(child);
		}
	}
</script>
</body>
</html>